<!-- 二次封装的饼状图 -->
<template>
  <div id="pieEcharts">
    <myCard :title="seriesDataInfo.name">
      <template #default>
        <myEcharts v-bind="seriesDataInfo" :option="option" />
      </template>
    </myCard>
  </div>
</template>

<script lang="ts" setup>
import { defineProps, withDefaults, computed } from 'vue'

import myEcharts from '..'
import myCard from '@/base-ui/card'

import type { PieEchartsTypes } from '..'

interface PropsTypes {
  // 图表数据
  seriesDataInfo: PieEchartsTypes
}

const props = withDefaults(defineProps<PropsTypes>(), {})

const option = computed(() => {
  return {
    tooltip: {
      trigger: 'item'
    },
    // legend: {
    //   orient: 'horizontal',
    //   top: 'left'
    // },
    series: [
      {
        name: props.seriesDataInfo.name,
        type: 'pie',
        radius: '80%',
        data: props.seriesDataInfo.data,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
})
</script>

<style scoped lang="less"></style>
